﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<Template>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
<% this.Title = JSC.Portal.Web.App.Resources.Msg.TemplateManagement;  %>
<script type="text/javascript">
$(document).ready(function() {
    $("#formulier").validate(
    {
        rules:
        {
            Name: "required",
            Path: "required",
            ControlName: "required",
            Css: "required"
        },
        messages:
        {
            Name: "*",
            Path: "*",
            ControlName: "*",
            Css: "*"
        }
    });
    GetTemplateSelect();
});

function GetTemplateSelect() {
    var selectedpath = $("#path").val();
    var renderContainer = $("#templateselect");
    if (selectedpath != '') {
        var url = '/portal/<%= ControllerNames.TEMPLATES_CONTROLLER %><%= SiteSettings.APP_EXTENSION %>/GetTemplateSelect/<%= ViewData.Model.Id %>?path=' + selectedpath;
        $.get(url, function(data) {
            renderContainer.html(data);
            renderContainer.fadeIn('slow');
        });
    }
    else {
        renderContainer.html('');
    }
}

function Delete() {
    if (confirm('<%= JSC.Portal.Web.App.Resources.Msg.AreYouSureYouWantToDeleteThis %>')) {
        window.location = '<%= Url.Action("Delete", new { id = ViewData.Model.Id }) %>';
    }
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="formulier" method="post" action="<%= Url.Action("SaveOrUpdate", new { id = ViewData.Model.Id }) %>">
    <fieldset class="contentfieldset">
        <legend><%= JSC.Portal.Web.App.Resources.Msg.General %></legend>
        <table border="0">
            <% Html.RenderPartial("DescriptiveEntityEditControl"); %>
        </table>
    </fieldset>
    <fieldset class="contentfieldset">
        <legend><%= JSC.Portal.Web.App.Resources.Msg.ModuleType %></legend>
        <table border="0">
            <tr>
                <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.Path %></td>
                <td><%= Html.TextBoxFor(model => model.Path) %>&nbsp;<%= Html.GridLinkButton(JSC.Portal.Web.App.Resources.Msg.CheckForTemplates, "javascript:GetTemplateSelect()")%></td>
            </tr>
            <tbody id="templateselect">
            
            </tbody>
        </table>    
    </fieldset>
    <br />
    <div class="button-bar-right">
        <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Cancel, Url.Action("List"))%>
        <%= Html.SeperatorRight() %>
        <% if (ViewData.Model.CanDelete) { %>
        <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Delete, "javascript:Delete()")%>
        <% } %>
        <%= Html.SeperatorRight() %>
        <%= Html.SubmitButtonRight(JSC.Portal.Web.App.Resources.Msg.Save)%>
    </div>
</form>
</asp:Content>
